using IQIGame.Onigao.Framework;
using IQIGame.Onigao.Game;
using System.Collections.Generic;

namespace IQIGame.Onigao.GamePlay
{
    public class UD_HeroUpLv : UIBaseData
    {
        public HeroData heroData { get; private set; }

        /// <summary>
        /// 是否觉醒升级
        /// </summary>
        public bool isUpAwaken { get; private set; }
        public int lastLv { get; private set; }

        private List<int> lastLvAttributeValues;

        public UD_HeroUpLv() { }


        public UD_HeroUpLv SyncUpAwakenLevel(HeroData heroData, int lastLv)
        {
            this.heroData = heroData;
            this.lastLv = lastLv;
            this.isUpAwaken = true;
            return this;
        }

        public UD_HeroUpLv SyncUpLeve(HeroData heroData, int lastLv, List<int> lastAttributes)
        {
            this.heroData = heroData;
            this.lastLv = lastLv;
            this.isUpAwaken = false;
            this.lastLvAttributeValues = lastAttributes;
            return this;
        }

        public int GetAttributeValue(int index)
        {
            if (lastLvAttributeValues != null && index < lastLvAttributeValues.Count)
                return lastLvAttributeValues[index];
            return 0;
        }

        public void Clear()
        {
            heroData = null;
            lastLv = 0;
            isUpAwaken = false;
            if (lastLvAttributeValues != null)
                ListPool<int>.Put(lastLvAttributeValues);
            lastLvAttributeValues = null;
        }

        #region 对象池

        public override void OnReset()
        {
            this.Clear();
        }

        static public UD_HeroUpLv NewFromPool()
        {
            return ClassPool<UD_HeroUpLv>.Get();
        }
        #endregion
    }
}
